Update _gtk_button_paint() arguments to GtkStyleContext
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 10 Jan 2011 01:26:28 +0000 (02:26 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Mon, 10 Jan 2011 02:49:59 +0000 (03:49 +0100)
The detail strings weren't in use anymore, and the state
argument is now a GtkStateFlags. GtkToggleButton has been
updated as well.

gtk/gtkbutton.c
gtk/gtkbutton.h
gtk/gtktogglebutton.c

index 374d7df935178d4dbb89356cf413112f8818df2a..d86ca465286160b983ecb15c2472e66cab3c9b0e 100644 (file)
@@ -1555,10 +1555,7 @@ _gtk_button_paint (GtkButton          *button,
                   cairo_t            *cr,
                    int                 width,
                    int                 height,
-                  GtkStateType        state_type,
-                  GtkShadowType       shadow_type,
-                  const gchar        *main_detail,
-                  const gchar        *default_detail)
+                  GtkStateFlags       state)
 {
   GtkButtonPrivate *priv = button->priv;
   GtkWidget *widget;
@@ -1571,12 +1568,12 @@ _gtk_button_paint (GtkButton          *button,
   GtkAllocation allocation;
   GdkWindow *window;
   GtkStyleContext *context;
-  GtkStateFlags state;
 
   widget = GTK_WIDGET (button);
-
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
+
+  gtk_style_context_save (context);
+  gtk_style_context_set_state (context, state);
 
   gtk_button_get_props (button, &default_border, &default_outside_border, NULL, &interior_focus);
   gtk_style_context_get_style (context,
@@ -1616,9 +1613,6 @@ _gtk_button_paint (GtkButton          *button,
       height -= 2 * (focus_width + focus_pad);
     }
 
-  state = gtk_widget_get_state_flags (widget);
-  gtk_style_context_set_state (context, state);
-
   if (priv->relief != GTK_RELIEF_NONE || priv->depressed ||
       state & GTK_STATE_FLAG_PRELIGHT)
     {
@@ -1671,6 +1665,8 @@ _gtk_button_paint (GtkButton          *button,
 
       gtk_border_free (border);
     }
+
+  gtk_style_context_restore (context);
 }
 
 static gboolean
@@ -1678,14 +1674,11 @@ gtk_button_draw (GtkWidget *widget,
                 cairo_t   *cr)
 {
   GtkButton *button = GTK_BUTTON (widget);
-  GtkButtonPrivate *priv = button->priv;
 
   _gtk_button_paint (button, cr, 
                      gtk_widget_get_allocated_width (widget),
                      gtk_widget_get_allocated_height (widget),
-                     gtk_widget_get_state (widget),
-                     priv->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
-                     "button", "buttondefault");
+                     gtk_widget_get_state_flags (widget));
 
   GTK_WIDGET_CLASS (gtk_button_parent_class)->draw (widget, cr);
 
index 0bab7e6ae37f65fe9cb855a2dc9355a8bebc01d8..2ad602e8d27c143f92e50cff8e0e3faff22ece6d 100644 (file)
@@ -127,10 +127,7 @@ void _gtk_button_paint                     (GtkButton          *button,
                                             cairo_t            *cr,
                                             int                 width,
                                             int                 height,
-                                           GtkStateType        state_type,
-                                           GtkShadowType       shadow_type,
-                                           const gchar        *main_detail,
-                                           const gchar        *default_detail);
+                                           GtkStateFlags       state);
 
 G_END_DECLS
 
index 7b8ae49f620639faf32621703af44b32212fbf07..43dbd49a9e27a584e4548c42b3fd8c14a717a957 100644 (file)
@@ -471,25 +471,19 @@ gtk_toggle_button_draw (GtkWidget *widget,
   GtkToggleButtonPrivate *priv = toggle_button->priv;
   GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
   GtkButton *button = GTK_BUTTON (widget);
-  GtkStateType state_type;
-  GtkShadowType shadow_type;
+  GtkStateType state;
 
-  state_type = gtk_widget_get_state (widget);
+  state = gtk_widget_get_state_flags (widget);
 
   if (priv->inconsistent)
-    {
-      if (state_type == GTK_STATE_ACTIVE)
-        state_type = GTK_STATE_NORMAL;
-      shadow_type = GTK_SHADOW_ETCHED_IN;
-    }
-  else
-    shadow_type = button->priv->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
+    state |= GTK_STATE_FLAG_INCONSISTENT;
+  else if (button->priv->depressed)
+    state |= GTK_STATE_FLAG_ACTIVE;
 
   _gtk_button_paint (button, cr,
                      gtk_widget_get_allocated_width (widget),
                      gtk_widget_get_allocated_height (widget),
-                     state_type, shadow_type,
-                     "togglebutton", "togglebuttondefault");
+                     state);
 
   if (child)
     gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr);